package ControlLayer;
import ModelLayer.*;
import java.util.*;

/**
 * Write a description of class OrderTypeCtr here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class OrderTypeCtr
{
    // instance variables - replace the example below with your own
    private OrderTypeLib orderTypeLib;

    private static OrderTypeCtr instance;
    /**
     * Constructor for objects of class OrderTypeCtr
     */
    private OrderTypeCtr()
    {
        // initialise instance variables
       orderTypeLib = OrderTypeLib.getOrderTypeLib();
       OrderType ot1 = new OrderType(1, "Delivery");
       orderTypeLib.addOrderType(ot1);
       OrderType ot2 = new OrderType(2, "Cash");
       orderTypeLib.addOrderType(ot2);
       OrderType ot3 = new OrderType(3, "Rental");
       orderTypeLib.addOrderType(ot3);
       OrderType ot4 = new OrderType(4, "Contracer deal");
       orderTypeLib.addOrderType(ot4);
    }

    public static OrderTypeCtr getOrderTypeCtr()
    {
        if(instance == null)
        {
            instance = new OrderTypeCtr();
        }
        
        return instance;
    }
    
    public OrderType getOrderTypeById(int _orderTypeId)
    {
        return orderTypeLib.getOrderTypeById(_orderTypeId);
    }
    
    public String getAllOrderTypes()
    {
        String orderTypes = "Ordre typer:" + "\n";
        ArrayList<OrderType> lstOrderTypes = orderTypeLib.getAllOrderTypes();
        
        for(OrderType type : lstOrderTypes)
        {
            orderTypes += " ID: " + type.getTypeId() + " - " + type.getType() + "\n";
        }
        
        return orderTypes;
    }
}
